package io.renren.modules.sys.controller;

import io.renren.common.page.PageData;
import io.renren.common.utils.Result;
import io.renren.modules.sys.dto.CaseCreateDTO;
import io.renren.modules.sys.service.CaseService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author jinpf
 * @date 2025-03-13
 */
@RestController
@RequestMapping("/case")
public class CaseController {

    @Resource
    private CaseService caseService;

    @PostMapping("/create")
    public Result<Boolean> createCase(@RequestBody CaseCreateDTO caseCreateDTO) {
        caseService.createCase(caseCreateDTO);
        return new Result<Boolean>().ok(true);
    }

    @GetMapping("/delete")
    public Result<Boolean> deleteCase(@RequestParam("id") Integer id) {
        caseService.deleteCase(id);
        return new Result<Boolean>().ok(true);
    }

    @PostMapping("/update")
    public Result<Boolean> updateCase(@RequestBody CaseCreateDTO caseCreateDTO) {
        caseService.updateCase(caseCreateDTO);
        return new Result<Boolean>().ok(true);
    }

    @GetMapping("/page")
    public Result<PageData<CaseCreateDTO>> getCase(@RequestParam Map<String, Object> params) {
        return new Result<PageData<CaseCreateDTO>>().ok(caseService.getPage(new CaseCreateDTO()));
    }

}
